home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 June: Reference Library / Dev.CD Jun 95 / Dev.CD Jun 95.toast / What's New? / New System Software Extensions / QuickDraw 3D ß / Programming / Interfaces / QD3DSet.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-04  |  8.4 KB  |  268 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DSet.h                                                 **
  4.  **                                                                             **
  5.  **                                                                             **
  6.  **     Purpose:     Set types and routines                                     **
  7.  **                                                                             **
  8.  **                                                                             **
  9.  **     Copyright (C) 1992-1995 Apple Computer, Inc.  All rights reserved.     **
  10.  **                                                                             **
  11.  **                                                                             **
  12.  *****************************************************************************/
  13. #ifndef QD3DSet_h
  14. #define QD3DSet_h
  15.  
  16. #if PRAGMA_ONCE
  17.     #pragma once
  18. #endif
  19.  
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif    /* __cplusplus */
  23.  
  24. /******************************************************************************
  25.  **                                                                             **
  26.  **                                Set Types                                     **
  27.  **                                                                             **
  28.  *****************************************************************************/
  29.  
  30. typedef long                    TQ3ElementType;
  31.  
  32. #define kQ3ElementTypeNone        0
  33. #define kQ3ElementTypeUnknown    32
  34.  
  35. /* kQ3ElementTypeUnknown is an TQ3Object. 
  36.     Do Q3Set_Add(s, ..., &obj) or Q3Set_Get(s, ..., &obj);
  37.     Note that the object is always referenced.
  38. */
  39.  
  40. /******************************************************************************
  41.  **                                                                             **
  42.  **                                Set Routines                                 **
  43.  **                                                                             **
  44.  *****************************************************************************/
  45.  
  46. EXPORT TQ3SetObject Q3Set_New(
  47.     void);
  48.  
  49. EXPORT TQ3ObjectType Q3Set_GetType(
  50.     TQ3SetObject        set);
  51.  
  52. EXPORT TQ3Status Q3Set_Add(
  53.     TQ3SetObject         set, 
  54.     TQ3ElementType        type,
  55.     const void             *data);
  56.  
  57. EXPORT TQ3Status Q3Set_Get(
  58.     TQ3SetObject         set,
  59.     TQ3ElementType        type,
  60.     void                *data);
  61.  
  62. EXPORT TQ3Boolean Q3Set_Contains(
  63.     TQ3SetObject         set,
  64.     TQ3ElementType        type);
  65.  
  66. EXPORT TQ3Status Q3Set_Clear(
  67.     TQ3SetObject         set, 
  68.     TQ3ElementType        type);
  69.  
  70. EXPORT TQ3Status Q3Set_Empty(
  71.     TQ3SetObject         target);
  72.  
  73. /*
  74.  *  Iterating through all elements in a set
  75.  *
  76.  *  Pass in kQ3ElementTypeNone to get first type
  77.  *  kQ3ElementTypeNone is returned when end of list is reached
  78.  */
  79. EXPORT TQ3Status Q3Set_GetNextElementType(
  80.     TQ3SetObject         set,
  81.     TQ3ElementType        *type);        
  82.  
  83. /******************************************************************************
  84.  **                                                                             **
  85.  **                                Attribute Types                                 **
  86.  **                                                                             **
  87.  *****************************************************************************/
  88.  
  89. /* 
  90.  *    For the data types listed below, pass in a pointer to it in the _Add 
  91.  *    and _Get calls.
  92.  *
  93.  *    For surface shader attributes, reference counts are incremented on 
  94.  *    the _Add and _Get 
  95.  */
  96.  
  97. typedef enum TQ3AttributeTypes {                /* Data Type                */
  98.     kQ3AttributeTypeNone                =  0,    /* ---------                */
  99.     kQ3AttributeTypeSurfaceUV            =  1,    /* TQ3Param2D                */ 
  100.     kQ3AttributeTypeShadingUV            =  2,    /* TQ3Param2D                 */
  101.     kQ3AttributeTypeNormal                =  3,    /* TQ3Vector3D                 */
  102.     kQ3AttributeTypeAmbientCoefficient    =  4,    /* float                     */
  103.     kQ3AttributeTypeDiffuseColor        =  5,    /* TQ3ColorRGB                */
  104.     kQ3AttributeTypeSpecularColor        =  6,    /* TQ3ColorRGB                */
  105.     kQ3AttributeTypeSpecularControl        =  7,    /* float                    */
  106.     kQ3AttributeTypeTransparencyColor    =  8,    /* TQ3ColorRGB                */
  107.     kQ3AttributeTypeSurfaceTangent        =  9,    /* TQ3Tangent2D              */
  108.     kQ3AttributeTypeHighlightState        = 10,    /* TQ3Boolean                 */
  109.     kQ3AttributeTypeSurfaceShader        = 11,    /* TQ3SurfaceShaderObject    */
  110.     kQ3AttributeTypeNumTypes
  111. } TQ3AttributeTypes;
  112.  
  113. typedef TQ3ElementType TQ3AttributeType;
  114.  
  115. /******************************************************************************
  116.  **                                                                             **
  117.  **                                Attribute Drawing                             **
  118.  **                                                                             **
  119.  *****************************************************************************/
  120.  
  121. EXPORT TQ3Status Q3Attribute_Submit(
  122.     TQ3AttributeType        attributeType,
  123.     const void                *data,
  124.     TQ3ViewObject            view);
  125.  
  126. /******************************************************************************
  127.  **                                                                             **
  128.  **                            AttributeSet Routines                             **
  129.  **                                                                             **
  130.  *****************************************************************************/
  131.  
  132. EXPORT TQ3AttributeSet Q3AttributeSet_New(
  133.     void);
  134.  
  135. EXPORT TQ3Status Q3AttributeSet_Add(
  136.     TQ3AttributeSet         attributeSet, 
  137.     TQ3AttributeType        type,
  138.     const void                 *data);
  139.  
  140. EXPORT TQ3Boolean Q3AttributeSet_Contains(
  141.     TQ3AttributeSet            attributeSet,
  142.     TQ3AttributeType        attributeType);
  143.  
  144. EXPORT TQ3Status Q3AttributeSet_Get(
  145.     TQ3AttributeSet         attributeSet,
  146.     TQ3AttributeType        type,
  147.     void                    *data);
  148.  
  149. EXPORT TQ3Status Q3AttributeSet_Clear(
  150.     TQ3AttributeSet         attributeSet,
  151.     TQ3AttributeType        type);
  152.  
  153. EXPORT TQ3Status Q3AttributeSet_Empty(
  154.     TQ3AttributeSet         target);
  155.  
  156. /*
  157.  * Q3AttributeSet_GetNextAttributeType
  158.  *
  159.  * Pass in kQ3AttributeTypeNone to get first type
  160.  * kQ3AttributeTypeNone is returned when end of list is reached
  161.  */
  162. EXPORT TQ3Status Q3AttributeSet_GetNextAttributeType(
  163.     TQ3AttributeSet         source,
  164.     TQ3AttributeType        *type);        
  165.  
  166. EXPORT TQ3Status Q3AttributeSet_Submit(
  167.     TQ3AttributeSet            attributeSet, 
  168.     TQ3ViewObject            view);
  169.  
  170. /******************************************************************************
  171.  **                                                                             **
  172.  **                            Custom Element Registration                         **
  173.  **                                                                             **
  174.  *****************************************************************************/
  175.  
  176. /*
  177.  * Element Methods - For copying data in _Add and _Get
  178.  *
  179.  * Notes on use:
  180.  *         When you create a custom element, you control what structures are 
  181.  *        passed around the API. For example, you may allow the Q3Set_Add call 
  182.  *        take one type of argument, store your element internally in some 
  183.  *        abstract data type, and have the Q3Set_Get call take a different 
  184.  *        argument.
  185.  *
  186.  *        For example:
  187.  *            
  188.  *
  189.  *        There are four calls which at some point will copy an element:
  190.  *
  191.  *        Q3Set_Add (copied from Application memory to QuickDraw3D memory)
  192.  *        Q3Set_Get (copied from QuickDraw3D memory to Application memory)
  193.  *        Q3Object_Duplicate (all elements are copied internally)
  194.  *        Q3AttributeSet_Inherit (may copy an Attribute in an AttributeSet)
  195.  *
  196.  *         Either CopyAdd or CopyReplace is called during the "_Add" call.
  197.  *            - CopyAdd is destructive and should assume "toElement" is garbage
  198.  *            - CopyReplace is replacing an existing element.
  199.  *
  200.  *         CopyGet is called during the "_Get" call.
  201.  *
  202.  *         CopyDuplicate is called to duplicate an element's internal structure.
  203.  *
  204.  */
  205. #define kQ3MethodTypeElementCopyAdd            Q3_METHOD_TYPE('e','c','p','a')
  206. #define kQ3MethodTypeElementCopyReplace        Q3_METHOD_TYPE('e','c','p','r')
  207. #define kQ3MethodTypeElementCopyGet            Q3_METHOD_TYPE('e','c','p','g')
  208. #define kQ3MethodTypeElementCopyDuplicate    Q3_METHOD_TYPE('e','c','p','d')
  209. #define kQ3MethodTypeElementDelete            Q3_METHOD_TYPE('e','d','e','l')
  210.  
  211. typedef TQ3Status (*TQ3ElementCopyAddMethod)(    
  212.     const void            *fromAPIElement,            /* element from _Add API call */
  213.     void                *toInternalElement);        /* to new QD3D internal element */
  214.  
  215. typedef TQ3Status (*TQ3ElementCopyReplaceMethod)(
  216.     const void            *fromAPIElement,            /* element from _Add API call */
  217.     void                *ontoInternalElement);        /* replacing QD3D internal element */
  218.  
  219. typedef TQ3Status (*TQ3ElementCopyGetMethod)(
  220.     const void            *fromInternalElement,        /* from QD3D internal element */
  221.     void                *toAPIElement);                /* to _Get API call */
  222.  
  223. typedef TQ3Status (*TQ3ElementCopyDuplicateMethod)(
  224.     const void            *fromInternalElement,        /* from QD3D internal element */
  225.     void                *toInternalElement);        /* to new QD3D internal element */
  226.  
  227. typedef TQ3Status (*TQ3ElementDeleteMethod)(    
  228.     void                *internalElement);
  229.  
  230. EXPORT TQ3ObjectClass Q3ElementClass_Register(
  231.      TQ3ElementType        elementType,
  232.     const char            *name,
  233.     unsigned long        sizeOfElement,
  234.     TQ3MetaHandler        metaHandler);
  235.  
  236. EXPORT TQ3Status Q3ElementType_GetElementSize(
  237.      TQ3ElementType        elementType,
  238.     unsigned long        *sizeOfElement);
  239.  
  240. /******************************************************************************
  241.  **                                                                             **
  242.  **                        Custom Attribute Registration                         **
  243.  **                                                                             **
  244.  *****************************************************************************/
  245.  
  246. #define kQ3MethodTypeAttributeInterpolate    Q3_METHOD_TYPE('i','n','t','p')
  247. #define kQ3MethodTypeAttributeInherit        Q3_METHOD_TYPE('i','n','h','t')
  248.  
  249. typedef TQ3Status (*TQ3AttributeInterpolateMethod)(
  250.     const void            *value1,
  251.     const void            *value2,
  252.     float                weight,
  253.     void                 *result);
  254.  
  255. typedef TQ3Boolean TQ3AttributeInheritMethod;
  256.  
  257. EXPORT TQ3ObjectClass Q3AttributeClass_Register(
  258.     TQ3AttributeType    attributeType,
  259.     const char            *creatorName,
  260.     unsigned long        sizeOfElement,
  261.     TQ3MetaHandler        metaHandler);
  262.  
  263. #ifdef __cplusplus
  264. }
  265. #endif    /* __cplusplus */
  266.  
  267. #endif /*  QD3DSet_h */
  268.